#define _GNU_SOURCE
#include "app_pthread_pool.h"
#include "unistd.h"

int task_func(void *arg)
{
    printf("task_func线程执行(%d): %s\n",gettid(), (char *)arg);
    return 0;
}

int main(int argc, char const *argv[])
{
    printf("main线程启动(%d)\n",gettid());
    // 初始化线程池
    pthread_pool_init(5);
    // 注册10个任务
    for (int i = 0; i < 10; i++)
    {
        char *data = (char *)malloc(sizeof(char));
        sprintf(data, "%d", i);
        pthread_pool_registerTask(task_func, data);
    }
    sleep(1);
    printf("main线程结束(%d)\n",gettid());
    // pthread_pool_destroy();

    return 0;
}

